import 'dart:math';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:book_manager_app/app/utils/common/app_manager.dart';
import '../../../utils/widget/common.dart';
import '../controllers/home_controller.dart';
import 'package:book_manager_app/app/theme/text_style.dart';
import 'scanner_book_view.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const NavigationTitle(title: '首页'),
        actions: [
          NavigatorItem(text: "退出", onTap: () {
            AppManager.signOut();
          }),
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              width: 200,
              child: MaterialButton(
                color: Colors.red,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10),
                ),
                padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
                onPressed: () {
                  // 跳转到扫码页面
                  Get.to(()=> ScannerBookView(callBack: controller.scannerCallBack));
                },
                child: Text(controller.buttonTitle.value, style: whiteStyle(font: 20)),
              ),
            ),
            const SizedBox(height: 150),
          ],
        )
      )
    );
  }


  Widget scannerView() {
    return Stack(
      children: [
        // 嵌入相机界面
        Positioned.fill(
          child: ScannerBookView(callBack: controller.scannerCallBack),
        ),
      ],
    );
  }
}

